﻿using System;
using System.ComponentModel;
using MVVM.Repository;
using MVVM.Model;

namespace MVVM.ViewModel {
    public class CustomerViewModel: ViewModel,INotifyPropertyChanged {

        Customer currentCustomer;

        public Customer CurrentCustomer {
            get { return currentCustomer; }
            set {
                if (currentCustomer != value) {
                    currentCustomer = value;
                    NotifyPropertyChanged("Customer");
                }
            }
        }

        public CustomerViewModel() {
            Initialize();
        }

        private void Initialize() {
            if (NavigationActions.DataContext != null) {
                CurrentCustomer = NavigationActions.DataContext as Customer;
            } else {
                CurrentCustomer = new Customer();
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(String info) {
            if (PropertyChanged != null) {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
}
